<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout">
<head>
    <meta charset="UTF-8" />
    <title>Cases Detail</title>
    <link rel="stylesheet" type="text/css" media="all" href="/layui/css/layui.css"/>
    <script type="text/javascript" src="/layui/layui.all.js"></script>
    <script type="text/javascript" src="/js/jquery.min.js"></script>
    <script type="text/javascript" src="/js/myJs.js"></script>
</head>
<body>

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>用户详情</legend>
</fieldset>
<br/><br/><br/>
<div class="layui-container">
    <!--6/12 布局-->
    <div class="layui-row">
        <div class="layui-col-xs6 layui-col-md-offset4">
            <form id="SourceForm" class="layui-form layui-form-pane">

                <div class="layui-form-item">
                    <label class="layui-form-label">ID</label>
                    <div class="layui-input-inline">
                        <input style="height: 38px;" type="text" name="employeeID" th:value="${t.employeeID}" readonly="readonly" autocomplete="off" class="layui-input layui-badge" />
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">登录名</label>
                    <div class="layui-input-inline">
                        <input style="height: 38px;" type="text" name="loginName" th:value="${t.loginName}" autocomplete="off" class="layui-input " />
                    </div>
                </div>


                <div class="layui-form-item">
                    <label class="layui-form-label">登录密码</label>
                    <div class="layui-input-inline">
                        <input type="password" name="password" autocomplete="off" class="layui-input" th:value="${t.password}" />
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">角色</label>
                    <div class="layui-input-inline">
                        <datalist id="modulelist">
                            <option value="master" > 管理员</option>
                            <option value="super" > 小编</option>
                            <option value="ordinary" > 普通用户</option>
                        </datalist>
                        <input type="text" list="modulelist" th:value="${t.power}" name="power" autocomplete="off" class="layui-input" />
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">所属人</label>
                    <div class="layui-input-inline">
                        <input type="text" name="realName" autocomplete="off" class="layui-input" th:value="${t.realName}" />
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">手机号码</label>
                    <div class="layui-input-inline">
                        <input type="text" name="phone" autocomplete="off" class="layui-input" th:value="${t.phone}" />
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">部门</label>
                    <div class="layui-input-inline">
                        <input type="text" name="depart" autocomplete="off" class="layui-input" th:value="${t.depart}" />
                    </div>
                </div>
                <!--提交按钮-->

                    <button type="reset" class="layui-btn" style="width: 300px" lay-filter="update" id="update" lay-submit="">立即提交</button>


            </form>
        </div>
    </div>
</div>

<script>
    function serializeObject(form){
        var o ={};
        $.each(form.serializeArray(),function(index){
            if(o[this['name']]){
                o[this['name']] = o[this['name']] +","+this['value'];

            }else{
                o[this['name']] = this['value'];
            }
        });
        return o;
    }
    //Demo
    layui.use('form', function(){
        var form = layui.form;
        form.render();
        //监听提交
        form.on('submit(update)', function(data){

            var form= $("#SourceForm");
            var model= serializeObject(form);
            $.ajax({
                type: "post",
                url: "/Request/updateOneEmployee",
                contentType: "application/json; charset=utf-8",
                data: JSON.stringify(model),
                dataType: "json",
                success: function(data) {
                    if (data=="true"){
                        layer.confirm('修改成功', function(index){
                            loadPage("/plateForm/Staff_EmployeeList");
                        });
                    }else {
                        layer.alert("修改失败");
                        loadPage("#");

                    }

                }
            });
        });
    });
</script>
</body>
</html>